<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/23
 * Time: 15:22
 * Project name: PHPTEST
 * File name: 4.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

//preg_replace_callback — 执行一个正则表达式搜索并且使用一个回调进行替换


/* 一个unix样式的命令行过滤器，用于将段落开始部分的大写字母转换为小写。 */
$fp = fopen( "php://stdin", "r" ) or die( "can't read stdin" );
while ( ! feof( $fp ) ) {
	$line = fgets( $fp );
	$line = preg_replace_callback(
		'|<p>\s*\w|',
		function ( $matches ) {
			return strtolower( $matches[0] );
		},
		$line
	);
	echo $line;
}
fclose( $fp );


